package test.equals;

/**
 * Created by shuoGG on 2018/7/4
 */
public class User {
    private int age;

    public User(int age) {
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        return this.age == ((User) o).age;
    }

    @Override
    public int hashCode() {
        String key = Integer.toString(age);
        int hash = 0;
        int i;
        for (i = 0; i < key.length(); ++i) hash = 33 * hash + key.charAt(i);
        return hash;
    }
}
